﻿import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Window
import FilUI

Popup {
    id: control
    padding                                     : 0
    modal                                       : true
    parent                                      : Overlay.overlay
    x                                           : Math.round((d.parentWidth - width) / 2)
    y                                           : Math.round((d.parentHeight - height) / 2)
    closePolicy                                 : Popup.NoAutoClose
    enter                                       : Transition {
        NumberAnimation {
            property                            : "opacity"
            duration                            : FilTheme.animationEnabled ? 83 : 0
            from                                : 0
            to                                  : 1
        }
    }
    height                                      : Math.min(implicitHeight, d.parentHeight)
    exit                                        : Transition {
        NumberAnimation {
            property                            : "opacity"
            duration                            : FilTheme.animationEnabled ? 83 : 0
            from                                : 1
            to                                  : 0
        }
    }
    background                                  : FilRectangle {
        radius                                  : [5, 5, 5, 5]
        color                                   : Qt.rgba(1, 1, 1, 1)
        FilShadow {
            radius                              : 5
        }
    }

    QtObject {
        id: d
        property int parentHeight               : {
            if (control.parent) {
                return control.parent.height
            }
            return control.height
        }
        property int parentWidth                : {
            if (control.parent) {
                return control.parent.width
            }
            return control.width
        }
    }
}
